-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Suspected logic bug in 'get_optional_params' #10245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Suspected logic bug in 'get_optional_params' #10245
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
f517e59
to
d81bdee
Compare
d81bdee
to
222eb3f
Compare
7f9e0f6
to
b4c7534
Compare
Only the if block could ever be reached, elif and else wouldn't due to the logic check going on above: BerriAI@4d2337e#diff-9661b0d8f1d9f48433f2323d1102e963d3098f667f7a25caea79f16fa282f6ddR5269 Extract params functions for get optional params and add tests
b4c7534
to
2158972
Compare
Deployment failed with the following error:
|
Hey @krrishdholakia and @ishaan-jaff apologies for tagging, but I opened an issue (#10244) and this PR in response... as I think there's something off here in the code. That said I'm not 100% I understand the full intent of the old code, so it may be that what I'm proposing isn't desirable and therefore may introduce subtly different bugs. I'd love it if anyone could take a look and let me know of any concerns or observations? Thanks 😄 |
Hi @peteski22 appreciate the PR, but i don't follow the test cases here. Can you give me a simple script to repro the issue? |
👋🏼 Hey @krrishdholakia I added more info and a small sample of code - on the issue, so it was captured in the same place. RE: Test cases: When trying to adjust/fix the logic errors I believe exist, I refactored some of the code and extracted parts to private methods in utils. Methods:
As a result, some of test cases are so that we can be certain we're getting the correct set of default params, non-default params from these new 'private' methods, and their values are what we expect. So if the code changes at a later date the tests will fail and we will be aware. Tests specific to each method are grouped under the relevant class in the test file:
Then there are the tests that exercise the changes to the logic within These tests try to exercise the conditions required to see the different code paths I called out in the issue.
I hope this helps. |
Bug: get_optional_params
PR for potential logic bug in
get_optional_params
(where the conditioncustom_llm_provider == "ollama"
means it will only ever beollama
).There was also a case where
function_call
could have been the only thing present in thenon_default_params
but the code didn't check/try to get the value to set it asoptional_params["functions_unsupported_model"]
.The PR adjusts this behaviour such that it is the same regardless of whether
custom_llm_provider
isollama
or not in the list ofopenai_compatible_providers
.I had to make a judgement call (so happy to get feedback here) that since the
if
/elif
statement forollama
checkedtools
thenfunctions
, thatfunction_call
would come after those two. So the order of precedence is:The
elif
code also seemed to treat it slightly differently and I'm not sure that was the intention.Note:
I added
__init__.py
files in the tests to prevent collisions with naming as there's already atest_utils.py
inside a test package but we didn't have them marked as packages.Relevant issues
Refs: #10244
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/
directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit
)[https://docs.litellm.ai/docs/extras/contributing_code]Type
🐛 Bug Fix
🧹 Refactoring
Changes
get_optional_params
to remove all function related optional params when they are supported and should be added to the prompt.Receipts